<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@taglib uri="http://www.goodfox.com/jsp/tags/power" prefix="p"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%> 
<script type="text/javascript">
$(function(){
	$("#excelName").val(encodeURI("林权证统计信息.xls"));
});
//将制定ID的table导入到excel中
function cpTab2Xls(tableId) {

    var curTbl = document.getElementById(tableId);
    var oXL = new ActiveXObject("Excel.Application");
    var oWB = oXL.Workbooks.Add();
    var oSheet = oWB.ActiveSheet;
    var sel = document.body.createTextRange();
    sel.moveToElementText(curTbl);
    sel.select();
    sel.execCommand("Copy");
    oSheet.Paste();
    oXL.Visible = true;

}
</script>

<div class="tabs">
	<div class="tabsHeader">
		<div class="tabsHeaderContent">
			<ul>
				<li><a href="javascript:;"><span>林权证统计结果</span></a></li>
			</ul>
		</div>
	</div>
	<div class="tabsContent">
		<div>
			<div class="panel collapse">
				<h1>高级查询</h1>
				<div>
					<form onsubmit="return navTabSearch(this);" action="<c:url value="/statistics/goStatisticsIndex.shtml"/>" method="post">
					<div class="searchBar">
						<table class="searchContent">
							<tr>
								<td>坐落：</td>
								<td colspan="5">
									<input type="hidden" name="areaId" id="areaId" value="${areaId}"/>
			                    	<input type="text" name="areaName" id="areaName" value="${areaName}" readonly="readonly" size="100"/>
		                    		<a class="btnLook" href="<c:url value="/rights/goAreaMultiLookup.shtml"/>" lookupGroup="">选择所属地区</a>
		                    		<a class="btnClean" href="javascript:;" onclick="$('#areaId').val('');$('#areaName').val('');">清空</a>
								</td>
							</tr>
							<tr>
								<td>林班：</td>
								<td>
									<input name="fst_class" id="fstc_lass" type="text" value="${fst_class}"/>
								</td>
								<td>小班：</td>
								<td>
									<input name="small_cls" id="small_cls" type="text" value="${small_cls}"/>
								</td>
								<td>主要树种：</td>
								<td>
									<select name="rights_query_species" id="rights_query_species">
										<option value="">--请选择--</option>
								        <c:forEach items="${speciesList}" var="atrSpecies">
								        	<option value="${atrSpecies.atrId}" <c:if test="${atrSpecies.atrId==rights_query_species}">selected="selected" </c:if>>${atrSpecies.atrName}</option>
							   			</c:forEach>
									</select>
								</td>
							</tr>
							<tr>
								<td>造林年度：</td>
								<td>	
									<input class="Wdate" type="text" id="rights_query_affDate" name="rights_query_affDate" onFocus="WdatePicker({dateFmt:'yyyy'})" readonly="readonly" value="${rights_query_affDate}"/>
								</td>
								<td>地类：</td>
								<td>
									<select name="rights_query_landType" id="rights_query_landType">
								    	<option value="">--请选择--</option>
								    	<c:forEach items="${landTypeList}" var="atrLandType">
								    		<option value="${atrLandType.atrValue}" <c:if test="${atrLandType.atrValue==rights_query_landType}">selected="selected" </c:if>>${atrLandType.atrName}</option>
								        </c:forEach>
								    </select>
								</td>
								<td>森林分类：</td>
								<td>
									<select name="rights_query_fstType" id="rights_query_fstType">
					                	<option value="">--请选择--</option>
					          			<c:forEach items="${fstTypeList}" var="atrFstType">
					           				<option value="${atrFstType.atrValue}" <c:if test="${atrFstType.atrValue==rights_query_fstType}">selected="selected" </c:if>>${atrFstType.atrName}</option>
					           			</c:forEach>
					                </select>
								</td>
							</tr>
							<tr>
								<td>林种：</td>
								<td>
									<select name="rights_query_fstSpecies" id="rights_query_fstSpecies">
					                	<option value="">--请选择--</option>
					          			<c:forEach items="${fstSpeciesList}" var="atrFstSpecies">
					           				<option value="${atrFstSpecies.atrValue}" <c:if test="${atrFstSpecies.atrValue==rights_query_fstSpecies}">selected="selected" </c:if>>${atrFstSpecies.atrName}</option>
					           			</c:forEach>
					                </select>
								</td>
								<td>是否退耕还林地：</td>
								<td>
									<select name="rights_query_backForest" id="rights_query_backForest">
								    	<option value="">--请选择--</option>
								        <option value="1" <c:if test="${'1'==rights_query_backForest}">selected="selected" </c:if>>是</option>
								        <option value="0" <c:if test="${'0'==rights_query_backForest}">selected="selected" </c:if>>否</option>
								    </select>
								</td>
								<td>登记类型：</td>
								<td>
									<select name="rights_query_rstType" id="rights_query_rstType">
						            	<option value="">--请选择--</option>
					          			<c:forEach items="${rstTypeList}" var="atrRstType">
					           				<option value="${atrRstType.atrValue}" <c:if test="${atrRstType.atrValue==rights_query_rstType}">selected="selected" </c:if>>${atrRstType.atrName}</option>
						       			</c:forEach>
								    </select>
					    		</td>
							</tr>
							<tr>
								<td>是否抵押：</td>
								<td colspan="5">
									<select name="rights_query_mortgage" id="rights_query_mortgage">
								    	<option value="">--请选择--</option>
								        <option value="1" <c:if test="${'1'==rights_query_mortgage}">selected="selected" </c:if>>是</option>
								        <option value="0" <c:if test="${'0'==rights_query_mortgage}">selected="selected" </c:if>>否</option>
								    </select>
								</td>
							</tr>
						</table>
						<div class="subBar">
							<ul>
								<li><div class="buttonActive"><div class="buttonContent"><button type="submit"><spring:message code="search.btnQuery"/></button></div></div></li>
							</ul>
						</div>
					</div>
					</form>
				</div>
			</div>
			<div id="jbsxBox" class="unitBox">
				<div class="pageContent" style="border-left: 1px solid #B8D0D6;border-right: 1px solid #B8D0D6;">
					<div class="panelBar">
						<ul class="toolBar">
							<li class="line">line</li>
					        <c:if test="${p:isPower('/statistics/exportStatisticsAll.shtml',sessionScope.loginAccount)}">
							<li><a class="icon" id="exportStatistics" target="dwzExport" targetType="navTab" title="确实要导出这些记录吗?" href="<c:url value="/statistics/exportStatisticsAll.shtml"/>"><span><spring:message code="search.btnExportXls"/></span></a></li>
							</c:if>
						</ul>
					</div>
					<form id="pagerForm" method="post" action="<c:url value="/statistics/goStatisticsIndex.shtml"/>">
						<input type="hidden" name="excelName" id="excelName" />
						<input type="hidden" name="areaId" value="${areaId}">
						<input type="hidden" name="areaName" value="${areaName}" />
						<input type="hidden" name="rights_query_species" value="${rights_query_species}" />
						<input type="hidden" name="rights_query_affDate" value="${rights_query_affDate}" />
						<input type="hidden" name="rights_query_landType" value="${rights_query_landType}" />
						<input type="hidden" name="rights_query_fstType" value="${rights_query_fstType}" />
						<input type="hidden" name="rights_query_fstSpecies" value="${rights_query_fstSpecies}" />
						<input type="hidden" name="rights_query_backForest" value="${rights_query_backForest}" />
						<input type="hidden" name="rights_query_rstType" value="${rights_query_rstType}" />
						<input type="hidden" name="rights_query_mortgage" value="${rights_query_mortgage}" />
					</form>
					<table class="table" width="100%" layoutH="275">
						<tbody>
							<c:forEach items="${forestStatisticsResultList}" var="countyResult">
								<tr>
									<td rowspan="${fn:length(countyResult.subResult)!=0?fn:length(countyResult.subResult):''}">${countyResult.areaName}</td>
									<td rowspan="${fn:length(countyResult.subResult)!=0?fn:length(countyResult.subResult):''}">${countyResult.forestRightsNum}林权证/${countyResult.woodlandNum}林地/${countyResult.woodlandAcreage}亩</td>
									<%//判断县级以下是否含有组织机构，如果没有，用TD占位，保持表格美观%>
									<c:if test="${fn:length(countyResult.subResult)==0}">
										<td></td>
										<td></td>
										<td></td>
										<td></td>
									</c:if>
									<%//循环乡级组织机构 %>
									<c:forEach items="${countyResult.subResult}" var="townshipResult" varStatus="townshipStatus">
										<%//如果不是一个县级下的第一个乡，另起一行;第一个乡与县级在同一行%>
										<c:if test="${!townshipStatus.first}"><tr></c:if>
											<td>${townshipResult.areaName}</td>
											<td>${townshipResult.forestRightsNum}林权证/${townshipResult.woodlandNum}林地/${townshipResult.woodlandAcreage}亩</td>
											
											<td>
												<c:forEach items="${townshipResult.subResult}" var="villageIdResult">
													<div class="divFakeRow">${villageIdResult.areaName}</div>
												</c:forEach>
											</td>
											<td>
												<c:forEach items="${townshipResult.subResult}" var="villageIdResult">
													<div class="divFakeRow">${villageIdResult.forestRightsNum}林权证/${villageIdResult.woodlandNum}林地/${villageIdResult.woodlandAcreage}亩</div>
												</c:forEach>
											</td>
										<%//如果是一个县级下的最后一个乡，结束该行%>
										<c:if test="${townshipStatus.last}"></tr></c:if>
										<c:if test="${townshipStatus.first}"></tr></c:if>
									</c:forEach>
								</c:forEach>
						</tbody>
					</table>
					<div class="panelBar">
						<div class="pages">
							<span>显示</span>
							<select class="numPerPageSet" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
								<option value="15">15</option>
								<option value="30">30</option>
								<option value="50">50</option>
							</select>
							<span>条，共${totalCount}条</span>
							<span>&lt;林权证：${totalCount}本。</span>
							<span>林地数：${woodlandCount}块。</span>
							<span>总面积：<fmt:formatNumber value="${acreageTotal}" pattern="0.00"/>亩&gt;</span>
						</div>
						<div class="pagination" targetType="navTab" totalCount="${totalCount}" numPerPage="${numPerPage}" pageNumShown="5" currentPage="${currentPage}"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="tabsFooter">
		<div class="tabsFooterContent"></div>
	</div>
</div>